// 色彩工具函数

export type ColorVariant = 'primary' | 'success' | 'warning' | 'error' | 'info' | 'gray'
export type ColorIntensity = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'
export type Priority = 'P0' | 'P1' | 'P2' | 'P3'
export type Category = 'work' | 'personal' | 'learning' | 'health' | 'other'

/**
 * 获取优先级颜色类名
 */
export function getPriorityColor(priority: Priority): string {
  const colorMap = {
    P0: 'priority-p0',
    P1: 'priority-p1', 
    P2: 'priority-p2',
    P3: 'priority-p3'
  }
  return colorMap[priority] || colorMap.P2
}

/**
 * 获取优先级文本颜色
 */
export function getPriorityTextColor(priority: Priority): string {
  const colorMap = {
    P0: 'text-red-600',
    P1: 'text-orange-600',
    P2: 'text-blue-600', 
    P3: 'text-green-600'
  }
  return colorMap[priority] || colorMap.P2
}

/**
 * 获取优先级背景颜色
 */
export function getPriorityBgColor(priority: Priority): string {
  const colorMap = {
    P0: 'bg-red-50',
    P1: 'bg-orange-50',
    P2: 'bg-blue-50',
    P3: 'bg-green-50'
  }
  return colorMap[priority] || colorMap.P2
}

/**
 * 获取优先级边框颜色
 */
export function getPriorityBorderColor(priority: Priority): string {
  const colorMap = {
    P0: 'border-red-200',
    P1: 'border-orange-200',
    P2: 'border-blue-200',
    P3: 'border-green-200'
  }
  return colorMap[priority] || colorMap.P2
}

/**
 * 获取分类颜色类名
 */
export function getCategoryColor(category: Category): string {
  const colorMap = {
    work: 'category-work',
    personal: 'category-personal',
    learning: 'category-learning',
    health: 'category-health',
    other: 'category-other'
  }
  return colorMap[category] || colorMap.other
}

/**
 * 获取分类文本颜色
 */
export function getCategoryTextColor(category: Category): string {
  const colorMap = {
    work: 'text-blue-600',
    personal: 'text-green-600',
    learning: 'text-purple-600',
    health: 'text-pink-600',
    other: 'text-gray-600'
  }
  return colorMap[category] || colorMap.other
}

/**
 * 获取分类背景颜色
 */
export function getCategoryBgColor(category: Category): string {
  const colorMap = {
    work: 'bg-blue-50',
    personal: 'bg-green-50',
    learning: 'bg-purple-50',
    health: 'bg-pink-50',
    other: 'bg-gray-50'
  }
  return colorMap[category] || colorMap.other
}

/**
 * 获取状态颜色
 */
export function getStatusColor(variant: ColorVariant): string {
  const colorMap = {
    primary: 'text-primary',
    success: 'text-success',
    warning: 'text-warning',
    error: 'text-error',
    info: 'text-info',
    gray: 'text-gray-500'
  }
  return colorMap[variant] || colorMap.gray
}

/**
 * 获取状态背景颜色
 */
export function getStatusBgColor(variant: ColorVariant): string {
  const colorMap = {
    primary: 'bg-primary-light',
    success: 'bg-success-light',
    warning: 'bg-warning-light', 
    error: 'bg-error-light',
    info: 'bg-info-light',
    gray: 'bg-gray-50'
  }
  return colorMap[variant] || colorMap.gray
}

/**
 * 获取按钮颜色类名
 */
export function getButtonColor(variant: ColorVariant): string {
  const colorMap = {
    primary: 'bg-primary hover-primary focus-primary text-white',
    success: 'bg-success hover-success focus-success text-white',
    warning: 'bg-warning hover-warning focus-warning text-white',
    error: 'bg-error hover-error focus-error text-white',
    info: 'bg-info text-white',
    gray: 'bg-gray-500 hover:bg-gray-600 text-white'
  }
  return colorMap[variant] || colorMap.primary
}

/**
 * 获取标签颜色类名
 */
export function getTagColor(variant: ColorVariant): string {
  const colorMap = {
    primary: 'bg-primary-light text-primary border-primary-light',
    success: 'bg-success-light text-success border-success-light',
    warning: 'bg-warning-light text-warning border-warning-light',
    error: 'bg-error-light text-error border-error-light',
    info: 'bg-info-light text-info border-info-light',
    gray: 'bg-gray-50 text-gray-600 border-gray-200'
  }
  return colorMap[variant] || colorMap.gray
}

/**
 * 根据任务状态获取颜色
 */
export function getTaskStatusColor(status: string): string {
  const statusMap = {
    'todo': 'text-gray-500',
    'in_progress': 'text-blue-600', 
    'review': 'text-yellow-600',
    'done': 'text-green-600',
    'cancelled': 'text-red-500'
  }
  return statusMap[status as keyof typeof statusMap] || statusMap.todo
}

/**
 * 根据任务状态获取背景颜色
 */
export function getTaskStatusBgColor(status: string): string {
  const statusMap = {
    'todo': 'bg-gray-50',
    'in_progress': 'bg-blue-50',
    'review': 'bg-yellow-50', 
    'done': 'bg-green-50',
    'cancelled': 'bg-red-50'
  }
  return statusMap[status as keyof typeof statusMap] || statusMap.todo
}

/**
 * 根据任务状态获取边框颜色
 */
export function getTaskStatusBorderColor(status: string): string {
  const statusMap = {
    'todo': 'border-gray-200',
    'in_progress': 'border-blue-200',
    'review': 'border-yellow-200',
    'done': 'border-green-200', 
    'cancelled': 'border-red-200'
  }
  return statusMap[status as keyof typeof statusMap] || statusMap.todo
}

/**
 * 生成渐变背景类名
 */
export function getGradientColor(variant: ColorVariant): string {
  const gradientMap = {
    primary: 'gradient-primary',
    success: 'gradient-success',
    warning: 'gradient-warning',
    error: 'gradient-error',
    info: 'bg-info',
    gray: 'bg-gray-500'
  }
  return gradientMap[variant] || gradientMap.primary
}

/**
 * 生成阴影类名
 */
export function getShadowColor(variant: ColorVariant): string {
  const shadowMap = {
    primary: 'shadow-primary',
    success: 'shadow-success',
    warning: 'shadow-warning',
    error: 'shadow-error',
    info: 'shadow-lg',
    gray: 'shadow-lg'
  }
  return shadowMap[variant] || shadowMap.primary
}
